﻿<%@ Page Language="C#" Theme="PAT_Theme" MasterPageFile="~/master/PAT.master" AutoEventWireup="true" CodeFile="CrearCita.aspx.cs" Inherits="aspx_tal01_CrearCita" Title="Crear Cita" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register src="../../ascx/FormNuevaCita.ascx" tagname="FormNuevaCita" tagprefix="uc1" %>
<asp:Content Id="headerContent" ContentPlaceHolderID="headerContent" runat="server">
    <script language="javascript">
        function validateDate(sender, args)
        {
            var today = Date.parseLocale(document.getElementById('<%=hdToday.ClientID %>').value,'<%=ConfigurationManager.AppSettings["DateFormat"] %>');
            var fecha = Date.parseLocale(document.getElementById('<%=txtFechaConsulta.ClientID %>').value,'<%=ConfigurationManager.AppSettings["DateFormat"] %>');
            if(fecha>=today)
                args.IsValid = true;
            else
                args.IsValid = false;
        }
    </script>
</asp:Content>
<asp:Content ID="mainContent" ContentPlaceHolderID="mainContent" Runat="Server">
    <asp:ValidationSummary ID="vsConsultar" runat="server" ShowMessageBox="True" 
        ShowSummary="False" ValidationGroup="vgConsultar" />
    <asp:HiddenField ID="hdToday" runat="server" />
    <table width="100%" border="0" cellpadding="1" cellspacing="1">
    <tr>
        <td>Empresas :
        </td>
        <td colspan="2">
            <asp:UpdatePanel ID="upnEmpresas" runat="server">
                <ContentTemplate>
                    <asp:DropDownList ID="ddlEmpresas" runat="server" 
                        onselectedindexchanged="ddlEmpresas_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
                    <asp:RequiredFieldValidator ID="rqEmpresas" runat="server" Display="None" 
                        ErrorMessage="Por favor seleccione una empresa" 
                        ValidationGroup="vgConsultar" ControlToValidate="ddlEmpresas"></asp:RequiredFieldValidator>
                </ContentTemplate>
            </asp:UpdatePanel>
        </td>
    </tr>
    <tr>
        <td>Sede Taller :</td>
        <td colspan="2">
            <asp:UpdatePanel ID="upnTalleres" runat="server" UpdateMode="Conditional">
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="ddlEmpresas" EventName="SelectedIndexChanged" />
                </Triggers>
                <ContentTemplate>
                    <asp:DropDownList ID="ddlTalleres" runat="server"></asp:DropDownList>
                    <asp:RequiredFieldValidator ID="rqTaller" runat="server" Display="None" 
                        ErrorMessage="Por favor seleccione un talller" 
                        ValidationGroup="vgConsultar" ControlToValidate="ddlTalleres"></asp:RequiredFieldValidator>
                </ContentTemplate>
            </asp:UpdatePanel>
        </td>        
    </tr>
    <tr>
        <td>Fecha de Consulta: </td>
        <td>
            <asp:TextBox ID="txtFechaConsulta" runat="server"></asp:TextBox>
            <asp:ImageButton ID="btnFechaConsulta" ImageUrl="~/App_Themes/PAT_Theme/images/calendar.png" runat="server" />
            <cc1:CalendarExtender ID="calTxtFechaConsulta" TargetControlID="txtFechaConsulta" PopupButtonID="btnFechaConsulta" runat="server">
            </cc1:CalendarExtender>
            <asp:CustomValidator ID="cmFecha" runat="server" 
                ErrorMessage="El valor de la fecha debe ser mayor o igual a hoy" 
                ClientValidationFunction="validateDate" Display="None" 
                ValidationGroup="vgConsultar"></asp:CustomValidator>
        </td>
        <td>
            <asp:UpdatePanel ID="upnBotonConsultar" runat="server">
                <ContentTemplate>
                    <asp:Button ID="btnConsultarMecanicos" runat="server" Text="Consultar" 
                            onclick="btnConsultarMecanicos_Click" ValidationGroup="vgConsultar" />
                    <asp:HiddenField ID="hdValueTaller" runat="server" />
                    <asp:HiddenField ID="hdValueNombreTaller" runat="server" />
                    <asp:HiddenField ID="hdValueDate" runat="server" />
                </ContentTemplate>
            </asp:UpdatePanel>            
        </td>
    </tr>
    <tr>
        <td colspan="3" align="center">
        <asp:UpdatePanel ID="upnGrilla" runat="server" UpdateMode="Conditional">
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnConsultarMecanicos" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="FormNuevaCita1" EventName="AcceptEvent" />
            </Triggers>
            <ContentTemplate>
                <asp:GridView ID="grdCitas" runat="server" AutoGenerateColumns="true" 
                    Width="98%" onrowdatabound="grdCitas_RowDataBound" CellSpacing="3">
                </asp:GridView>
            </ContentTemplate>
        </asp:UpdatePanel>
        </td>
    </tr>
</table>
<asp:UpdatePanel ID="upnFormaNuevaCita" runat="server" UpdateMode="Conditional">
        <ContentTemplate>        
            <cc1:ModalPopupExtender ID="mdlFormaNuevaCita" runat="server" 
                                    PopupControlID="pnlFormNuevaCita" 
                                    TargetControlID="lnkPopup"
                                    BackgroundCssClass="FondoAplicacion" />
            <asp:LinkButton ID="lnkPopup" runat="server" />
            <asp:Panel ID="pnlFormNuevaCita" runat="server" >
                <uc1:FormNuevaCita ID="FormNuevaCita1" runat="server" />
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
<asp:UpdatePanel ID="upnConfirmModal" runat="server" UpdateMode="Conditional">
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="FormNuevaCita1" EventName="AcceptEvent" />
    </Triggers>
    <ContentTemplate>
        <cc1:ModalPopupExtender ID="mdlConfirmModal" runat="server" 
                                    PopupControlID="pnlModalConfirm" 
                                    TargetControlID="lnkPopup2"
                                    BackgroundCssClass="FondoAplicacion" />
        <asp:LinkButton ID="lnkPopup2" runat="server" />
        <asp:Panel ID="pnlModalConfirm" runat="server" Width="380px" Height="120px" BackColor="White"  >
            <div style="width: 50%; margin: 0 auto; text-align: left">
                <asp:Label ID="lblConfirmText" runat="server"></asp:Label>
                <img src="../../App_Themes/PAT_Theme/images/alert-icon-red.jpeg" width="30%" height="30%" />
                <br />
                <asp:Button ID="btnCloseConfirmModal" runat="server" CausesValidation="false" Text="Cerrar" onclick="btnCloseConfirmModal_Click" />
            </div>
        </asp:Panel>
    </ContentTemplate>
</asp:UpdatePanel>
</asp:Content>